Download Secure Localization and Time Synchronization for Wireless Sensor and Ad Hoc Networks